{% extends "zhongjiang/base.html" %}
{%block header%}
  <link rel="stylesheet" href="/static/css/easydialog.css" type="text/css" />
  <link rel="stylesheet" href="/static/css/base.css" type="text/css" />
  <script src="/static/js/jquery.min.js" type="text/javascript"></script>
  <script src="/static/js/easydialog.js" type="text/javascript"></script>
  <script src="/static/js/pyqtmock.js" type="text/javascript"></script>
  
  <style type="text/css">
		.login_btn{
			margin-top:20px;
			background:url('/static/img/login_btn.png') no-repeat;
		}
	</style>
	
	<script type="text/javascript">
	    var lottery;
	    $(document).ready(function(){
		  	function go_home()
		  	{
		  		window.location.href="/";
		  	}
		  	setTimeout("go_home()",150000);
	    	
	    	$('#fangjiang').click(function(){
	    		if(parseInt({{hasbigprize}})>0){
	    			$('#err_msg').html("请进行大奖兑奖流程.");
	    			easyDialog.open({
	              		  container : 'msg_display',
	              		  autoClose : 2000,
	              		  fixed : false
	              	});
	    			return;
	    		}
                easyDialog.open({
                  container : "choose_fanjiang",
                  autocount : 20,
                  countid : 'backcount',
                  fixed : true
                });
                $('#acc_num').val('');
            	$('#password').val(''); 
        	}); 
	    	
	    	$('#password').click(function(){$('.input_keybord').show();});
	    	//软键盘数字键
	        $('i.bottom').click(function(){
	            //console.log($(this).children().html());
	            $('#password').val($('#password').val()+$(this).children().html());
	        });

	        //软键盘删除键
	        $('i.dele').click(function(){
	            var c = $('#password').val();
	            $('#password').val(c.slice(0,c.length-1));
	        });

	        //软键盘清空键
	        $('i.rest').click(function(){
	           $('#password').val(''); 
	        });
	        
	    	$('#ecard_code').bind('input',function(){
	    		ecard_value = $(this).val();
	    		if(ecard_value.length>9){
	    			$('#acc_num').val(ecard_value.slice(1,9));
	    			$('.input_keybord').show();
	    		}
	    	});
	    	$('#ecard_code').blur(function(){
	    		if($('#acc_num').val()==''){
	    			$('#ecard_code').focus();
	    		}
	    	});
	    });
	    
	     function btnFn(){
	    	$.ajax({
                type:'POST',
                dataType:'json',
                url:'/prize_confirm',
                data:{
                	acc_num : $('#acc_num').val(),
                    batchid:{{batchid}}
                },
                success:function(data,status){
                	$('#err_msg').html("返奖成功，请支付奖金");
                	easyDialog.open({
	              		  container : 'msg_display',
	              		  autoClose : 2000,
	              		  fixed : false
	              	});
                },
                error:function (req, status, error){
                	$('#err_msg').html(req.responseText);
                	easyDialog.open({
	              		  container : 'msg_display',
	              		  autoClose : 2000,
	              		  fixed : false
	              	});
                },
            });
	    };
	    
	    function chk_login(){
	    	$.ajax({
                type:'POST',
                dataType:'json',
                url:'/chk_login',
                data:{
                    acc_num : $('#acc_num').val(),
                    password : $('#password').val(),
                    mac:pyObj.get_if_mac()
                },
                success:function(data,status){
                	easyDialog.open({
          	    	  container : 'prizesure'
          	    	});
                },
                error:function (req, status, error){
                	$('#err_msg').html(req.responseText);
                	easyDialog.open({
	              		  container : 'msg_display',
	              		  autoClose : 2000,
	              		  fixed : false
	              	});
                },
            });
	    }
	    
	  	//测试mock
	    if(typeof(pyObj) == 'undefined'){
	        pyObj = {};

	        pyObj.get_if_mac = function(){
	            return "000000000030";
	        }
	    }
	    
	    function show_login(){
	    	easyDialog.open({
	    	  container : 'login'
	    	});
	    	$('#ecard_code').val('');
	    	$('#ecard_code').focus();
	    }
	    
  </script>
{%endblock%}
{%block tip%}
  		{% if hasbigprize %}
  			<div class="caipiaozhonglei_3" style="height:158px;">
  			<div class="caipiaozhonglei_33" style="height:158px;">
  		{% else %}
  			<div class="caipiaozhonglei_3">
  			<div class="caipiaozhonglei_33">
  		{% endif %}
  				<div class="duijaing_right"><input src="/static/img/botton_fanjiang.png" type="image" id="fangjiang"></div>
  				<div class="zhongjian_3" style="float:left;">
            <table>
              <tr><td><img src="/static/img/zhongjiang.png"></td><td><span style="color: #A21C00; font-size:2.6em;">
	              {% if hasbigprize %}
	              	恭喜!您已中大奖!<br>奖金<span style="font-size:1.5em;">{{awardmoney}}</span>元<br/>
	              	<span style="font-size:0.5em;">请联系江西汇然公司办理领奖事宜，电话：{{phone}}</span>
	              {% else %}
	              	恭喜!您的彩票中奖<br>奖金<span style="font-size:1.5em;">{{awardmoney}}</span>元
	              {% endif %}
              </span></td></tr>
            </table>  
          </div>
  			</div>
  		</div>


        <div id="choose_fanjiang" class="fanjiang_1" style="display:none;">
            <div class="fanjiang_11">
                <!-- <div style="padding-top:43px; padding-left:30px;"><input type="image" src="/static/img/ka_fanjiang.png"></div>  -->
          		<div style="padding-top:20px; padding-left:30px;"><a onclick="show_login();"><input type="image" src="/static/img/man_fanjiang.png"></a></div>
          		<div style="font-size: 0.8em;padding-left: 145px;padding-top: 20px;"><span id='backcount'>10</span>秒后返回主界面</div>
            </div>
        </div>
        
        <!-- 登录界面 -->
        <div class="daigou_1" style="height:396px;margin-left:459px;width:395px;display:none" id="login">
		  <div class="daigou_11" style="height:396px;">
		  <a onclick="easyDialog.close();" class="close"></a>
		    <div class="daigou-info">
		    	<input id="ecard_code" type="text" value="" class="scaninput"/>
		    	<span style="margin-left:15px;">账号</span><br>
		    	<input id="acc_num" type="text" class="input" style="margin-top:10px;" readonly="readonly">
		    </div>
		    <div class="daigou-info2" style="margin-top:10px;"><span style="margin-left:15px;">密码</span><br>
		    	<div><input id="password" type="password" class="input" style="margin-top:10px;"></div>
		        <div><img src="/static/img/login_btn.png" id="login_submit" onclick="chk_login();" style="margin-top:10px;"></div>
		    </div>
		  </div>
		
		  <div class="input_keybord" style="display:none;top:-342px;">
		    <i class="bottom"><span>7</span></i>
		    <i class="bottom"><span>8</span></i>
		    <i class="bottom"><span>9</span></i>
		    <br>
		    <i class="bottom"><span>4</span></i>
		    <i class="bottom"><span>5</span></i>
		    <i class="bottom"><span>6</span></i>
		    <br>
		    <i class="bottom"><span>1</span></i>
		    <i class="bottom"><span>2</span></i>
		    <i class="bottom"><span>3</span></i>
		    <br>
		    <i class="bottom"><span>0</span></i>
		    <i class="dele"><span></span></i>
		    <i class="rest"><span></span></i>
		  </div>
		</div>
		
		<div class="toubi_1" style="display:none;height: 121px;" id="msg_display">
		<div class="toubi_11" style="height: 121px">
			<div class="print-tikect"><span class="like-red" id="err_msg"></span></div>
		</div>
	</div>
	
	
	
	 <!-- 返奖确认界面 -->
        <div class="daigou_1" style="height:316px;margin-left:459px;width:395px;display:none" id="prizesure">
		  <div class="daigou_11" style="height:316px;">
		  <a onclick="easyDialog.close();" class="close"></a>
		    <div class="daigou-info"><span style="margin-left:80px;font-size:40px;color:#F75000;font-weight:bold;">返奖确认</span><br></div>
		    <div class="daigou-info2" style="margin-top:10px;"><span style="margin-left:15px;">中奖总金额：￥{{awardmoney}}</span><br></div>
		    <div class="daigou-info2" style="margin-top:10px;"><span style="margin-left:15px;">友情提示：现在兑奖请点击确定</span></div>
		  <div class="daigou-info2" style="margin-top:10px;"><span style="margin-left:15px;">下次兑奖请关闭页面。</span><br></div>
		  <div><img src="/static/img/daigouok.png" id="login_submit" onclick="btnFn();" style="margin-top:30px;margin-left:118px;"></div>
		  </div>
		</div>
	
{%endblock%}